home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / CBGRX103.ZIP / contrib / libgrx / drivers / tseng416.asm < prev    next >
Assembly Source File  |  1993-12-06  |  4KB  |  204 lines

  1. ; This is file TSENG416.ASM
  2. ;
  3. ; Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  4. ;
  5. ; This file is distributed under the terms listed in the document
  6. ; "copying.dj", available from DJ Delorie at the address above.
  7. ; A copy of "copying.dj" should accompany this file; if not, a copy
  8. ; should be available from where this file was obtained.  This file
  9. ; may not be distributed without a verbatim copy of "copying.dj".
  10. ;
  11. ; This file is distributed WITHOUT ANY WARRANTY; without even the implied
  12. ; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. ;
  14.  
  15. include grdriver.inc
  16. cseg    segment byte public 'code'
  17.     assume  cs:cseg, ds:cseg, es:cseg, ss:nothing
  18.  
  19.     dw    offset init_routine
  20.     dw    offset paging_routine
  21.     dw    GRD_VGA+GRD_4_PLANES+GRD_1024K+GRD_RW_64K
  22.  
  23. def_tw  dw    80    ; filled in by go32 if GO32 env. var. is set
  24. def_th  dw    25
  25. def_gw  dw    640
  26. def_gh  dw    480
  27.  
  28. ;--------------------------------------------------------------------------
  29. ; Entry: AX=mode selection
  30. ;        0=80x25 text
  31. ;        1=default text
  32. ;        2=text CX cols by DX rows
  33. ;        3=biggest text
  34. ;        4=320x200 graphics
  35. ;        5=default graphics
  36. ;        6=graphics CX width by DX height
  37. ;        7=biggest non-interlaced graphics
  38. ;        8=biggest graphics
  39. ;
  40. ; NOTE: This runs in real mode, but don't mess with the segment registers.
  41. ;
  42. ; Exit:  CX=width (in pixels or characters)
  43. ;     DX=height
  44.  
  45. init_table    label    word
  46.     dw    offset init_0
  47.     dw    offset init_1
  48.     dw    offset init_2
  49.     dw    offset init_3
  50.     dw    offset init_4
  51.     dw    offset init_5
  52.     dw    offset init_6
  53.     dw    offset init_7
  54.     dw    offset init_8
  55.  
  56. init_routine    proc    far
  57.     cmp    ax,8
  58.     jbe    valid_req
  59.     ret
  60. valid_req:
  61.     shl    ax,1
  62.     mov    bx,ax
  63.     jmp    init_table[bx]
  64.  
  65. init_0: ; 80x25 text
  66.     mov    ax,3
  67.     int    10h
  68.     mov    cx,80
  69.     mov    dx,25
  70.     ret
  71.  
  72. init_1: ; default text
  73.     mov    cx,def_tw
  74.     mov    dx,def_th
  75.     jmp    init_2
  76.  
  77. init_2_table    label    word
  78.     dw    01h, 40, 25
  79.     dw    03h, 80, 25
  80.     dw    2ah, 100, 40        ; added C.B. 04/13/91
  81.     dw    23h, 132, 25
  82.     dw    24h, 132, 28
  83.     dw    22h, 132, 44
  84.     dw    61h, 132, 50
  85. init_2_tend    label    word
  86.  
  87. init_2: ; CX*DX text
  88.     mov    si,offset init_2_table
  89. init_2a:
  90.     cmp    [si+2],cx
  91.     jb    init_2b
  92.     cmp    [si+4],dx
  93.     jb    init_2b
  94.     ; got a big enough one!
  95.     jmp    init_2c
  96. init_2b:
  97.     cmp    si,offset init_2_tend - 6
  98.     je    init_2c
  99.     add    si,6
  100.     jmp    init_2a
  101. init_2c:
  102.     mov    ax,[si]
  103.     push    si
  104.     int    10h
  105.     pop    si
  106.     mov    cx,[si+2]
  107.     mov    dx,[si+4]
  108.     ret
  109.  
  110. init_3: ; biggest text
  111.     mov    ax,[init_2_tend-6]
  112.     int    10h
  113.     mov    cx,[init_2_tend-4]
  114.     mov    dx,[init_2_tend-2]
  115.     ret
  116.  
  117. init_4: ; 320x200 graphics
  118.     mov    ax,0dh
  119.     int    10h
  120.     mov    cx,320
  121.     mov    dx,200
  122.     ret
  123.  
  124. init_5: ; default graphics - should be 640x480 if supported
  125.     mov    cx,def_gw
  126.     mov    dx,def_gh
  127.     jmp    init_6
  128.  
  129. init_6_table    label    word
  130.     dw    0dh, 320, 200
  131.     dw    0eh, 640, 200
  132.     dw    10h, 640, 350
  133.     dw    12h, 640, 480
  134.     dw    29h, 800, 600
  135.     dw    37h,1024, 768
  136. init_6_tend    label    word
  137.  
  138. init_6: ; CX*DX graphics
  139.     mov    si,offset init_6_table
  140. init_6a:
  141.     cmp    [si+2],cx
  142.     jb    init_6b
  143.     cmp    [si+4],dx
  144.     jb    init_6b
  145.     ; got a big enough one!
  146.     jmp    init_6c
  147. init_6b:
  148.     cmp    si,offset init_6_tend - 6
  149.     je    init_6c
  150.     add    si,6
  151.     jmp    init_6a
  152. init_6c:
  153.     mov    ax,[si]
  154.     push    si
  155.     int    10h
  156.     pop    si
  157.     mov    cx,[si+2]
  158.     mov    dx,[si+4]
  159.     ret
  160.  
  161. init_7: ; biggest non-interlaced graphics
  162.     mov    ax,29h
  163.     int    10h
  164.     mov    cx,800
  165.     mov    dx,600
  166.     ret
  167.  
  168. init_8: ; biggest graphics
  169.     mov    ax,37h
  170.     int    10h
  171.     mov    cx,1024
  172.     mov    dx,768
  173.     ret
  174.  
  175. init_routine    endp
  176.  
  177. ;--------------------------------------------------------------------------
  178. ; Entry: AH=read page
  179. ;     AL=write page
  180. ;
  181. ; NOTE: This runs in protected mode!  Don't mess with the segment registers!
  182. ; This code must be relocatable and may not reference any data!
  183. ;
  184. ; Exit: VGA configured.
  185. ;    AX,BX,CX,DX,SI,DI may be trashed
  186.  
  187.     assume  ds:nothing, es:nothing
  188.  
  189. paging_routine  proc    far
  190.     and    al,0fh
  191.     mov    cl,4
  192.     shl    ah,cl
  193.     and    ah,0f0h
  194.     or    al,ah
  195.     mov    dx,03cdh
  196.     out    dx,al
  197.     ret
  198. paging_routine  endp
  199.  
  200. ;--------------------------------------------------------------------------
  201.  
  202. cseg    ends
  203.     end
  204.